package sample.model;

import javafx.beans.property.SimpleStringProperty;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ZDYdataModel {
    private SimpleStringProperty serverName_ZDY = new SimpleStringProperty();//服务器名称
    private SimpleStringProperty hostIP_ZDY = new SimpleStringProperty();//IP地址
    private SimpleStringProperty MyCommand1 = new SimpleStringProperty();//MyCommand1
    private SimpleStringProperty MyCommand2 = new SimpleStringProperty();//系统cpu
    private SimpleStringProperty MyCommand3 = new SimpleStringProperty();//cpu wait
    private SimpleStringProperty MyCommand4 = new SimpleStringProperty();//cpu 空闲


    public ZDYdataModel(String serverName_ZDY, String hostIP_ZDY, String MyCommand1, String MyCommand2, String MyCommand3, String MyCommand4){
        this.serverName_ZDY.set(serverName_ZDY);
        this.hostIP_ZDY.set(hostIP_ZDY);
        this.MyCommand1.set(MyCommand1);
        this.MyCommand2.set(MyCommand2);
        this.MyCommand3.set(MyCommand3);
        this.MyCommand4.set(MyCommand4);
    }

    public String getMyCommand3() {
        return MyCommand3.get();
    }

    public SimpleStringProperty MyCommand3Property() {
        return MyCommand3;
    }

    public void setMyCommand3(String MyCommand3) {
        this.MyCommand3.set(MyCommand3);
    }

    public String getserverName_ZDY() {
        return serverName_ZDY.get();
    }

    public SimpleStringProperty serverName_ZDYProperty() {
        return serverName_ZDY;
    }

    public void setserverName_ZDY(String serverName_ZDY) {
        this.serverName_ZDY.set(serverName_ZDY);
    }

    public String gethostIP_ZDY() {
        return hostIP_ZDY.get();
    }

    public SimpleStringProperty hostIP_ZDYProperty() {
        return hostIP_ZDY;
    }

    public void sethostIP_ZDY(String hostIP_ZDY) {
        this.hostIP_ZDY.set(hostIP_ZDY);
    }

    public String getMyCommand1() {
        return MyCommand1.get();
    }

    public SimpleStringProperty MyCommand1Property() {
        return MyCommand1;
    }

    public void setMyCommand1(String MyCommand1) {
        this.MyCommand1.set(MyCommand1);
    }

    public String getMyCommand2() {
        return MyCommand2.get();
    }

    public SimpleStringProperty MyCommand2Property() {
        return MyCommand2;
    }

    public void setMyCommand2(String MyCommand2) {
        this.MyCommand2.set(MyCommand2);
    }

    public String getMyCommand4() {
        return MyCommand4.get();
    }

    public SimpleStringProperty MyCommand4Property() {
        return MyCommand4;
    }

    public void setMyCommand4(String MyCommand4) {
        this.MyCommand4.set(MyCommand4);
    }


    public String toString(){
        String str= ResultFormat(this.serverName_ZDY.getValue())+"\t"+
                    ResultFormat(this.hostIP_ZDY.getValue())+"\t"+
                    ResultFormat(this.MyCommand1.getValue())+"\t"+
                    ResultFormat(this.MyCommand2.getValue())+"\t"+
                    ResultFormat(this.MyCommand3.getValue())+"\t"+
                    ResultFormat(this.MyCommand4.getValue());
        return str;
    }

    //去掉一个字符串中的换行符、回车符等，将连续多个空格替换成一个空格
    public static String ResultFormat(String string){
        Pattern p = Pattern.compile("\t|\r|\n");
        Matcher m = p.matcher(string);
        string = m.replaceAll("");
        string = string.replaceAll(" +", " ");
        return string;
    }

}
